﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="editTvStationPeople.aspx.cs" Inherits="Com.CMS263.Web.manage.TvStation.editTvStationPeople" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
     <link href="../style/main.css" rel="stylesheet" type="text/css" />
    <script src="../../js/jquery-1.4.2.min.js" type="text/javascript"></script>
    <link href="../common/validator.css" rel="stylesheet" type="text/css" />
        <style type="text/css">
    .preview_fake{
             filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale);     
    }     
</style>
    <script type="text/javascript" language="javascript">
        $(function() {
            $("#updateImage").hide();          
        })
        function save() {
            if ($("#tvStationId").val() == "0") {
                alert("电视台必选！");
                $("#tvStationId").focus();
                return false;
            } else if ($("#Name").val().length < 1) {
                alert("姓名必填！");
                $("#Name").focus();
                return false;
            } else if ($("#headPic").val().length < 1) {
                alert("头像必填！");
                $("#headPic").focus();
                return false;
            } else {
                return true;
            }
        }
        $(document).ready(function() {
        $("#tvStationId option").each(function() {

        if ($(this).attr("value") == '<%=tvp.TvStationId %>') {
                    $(this).attr("selected", "selected");
                }

            })
        })
        function onUploadImgChange(sender, width, height, index) {
            $("#updateImage").show();
            $("#headPic").val($(sender).val());
            try {
                index = index == undefined ? "" : index;
                if (!sender.value.match(/.jpg|.gif|.png|.bmp/i)) {
                    alert('请上传.jpg|.gif|.png|.bmp类型的图片');
                    return false;
                }

                var objPreview = $(".preview_pic" + index);
                var objPreviewFake = document.getElementById('preview_fake' + index);

                if (sender.files && sender.files[0]) {
                    objPreview.show();
                    objPreview.attr("width", width);
                    objPreview.attr("height", height);

                    objPreview.attr("src", sender.files[0].getAsDataURL());



                } else if (objPreviewFake.filters) {
                    sender.select();
                    var imgSrc = document.selection.createRange().text;
                    objPreviewFake.filters.item('DXImageTransform.Microsoft.AlphaImageLoader').src = imgSrc;

                    objPreviewFake.style.width = width + 'px';
                    objPreviewFake.style.height = height + 'px';
                    objPreview.hide();
                    sender.blur();
                }
            } catch (ex) {
                alert(ex);
                alert("图片加载失败！");
            }
        }
    </script>
</head>
<body>
    <form id="form1" runat="server" enctype="multipart/form-data">
    <input  id="Id" name="Id" value="<%=tvp.Id %>" type="hidden"/>
    <input  id="pageTv" name="pageTv" value="<%=pageTv %>" type="hidden"/>
    <div>
        <table width="100%" border="0" align="left" cellpadding="0" cellspacing="0" class="table_1">
            <tr>
                <td height="23" colspan="2" class="table_2">
                    添加/修改 <asp:label runat="server" id="lbTypeName">电视台主持人</asp:label>
                </td>
            </tr>
             <tr>
                <td >
                    电视台:
                </td>
                <td >
                 <select name="tvStationId" id="tvStationId">
                 <option value="0">请选择...</option>
                 <%foreach (var item in tvList){
                      %>
                      
                      <option value="<%=item.Id %>"><%=item.Name %></option><%}%>                
                 </select>
                &nbsp;</td>
            </tr>  
            <tr>
                <td >
                    名称:
                </td>
                <td >
                 <input type="text" name="Name" id="Name" size="50" value="<%=tvp.Name %>"/>
                &nbsp;</td>
            </tr>  
            <tr>
                <td class="tdleft">
                    头像(152*164)：</td>
                <td class="tdside">                
                <img  id="changeHeadPic"  src="/ArtUpFile/<%=tvp.HeadPic %>" width="100px" height="100px"/>
                </td>
            </tr>
             <tr>
                <td class="tdleft">
                    设置新的头像：</td>
                <td class="tdside">                 
                    <input type='file' name="headPic" id="headPic"  value="<%=tvp.HeadPic %> "  onchange="onUploadImgChange(this,100,100);"/>  
                     <div id="updateImage">
      <div id="preview_fake" class="preview_fake">      
      <img  alt="" class="preview_pic" src="/ArtUpFile/<%=tvp.HeadPic %>"   width="100px" height="100px"/>      
      </div> 
      </div>                           
                </td>
            </tr>
          <tr>
                <td class="tdleft">
                    描述</td>
                <td class="tdside">               
                    
                    <textarea  name="description" id="description"  cols='45' rows='5'><%=tvp.Description %></textarea>
                </td>
            </tr>            
            <tr>
                    <td class="tdleft">
                       </td>
                    <td class="tdside">
                        <asp:Button ID="btnSave" runat="server" Text="保存" onclick="btnSave_Click"  OnClientClick="return save();" />                         
                  <input ID="Button1"   value="返回" type="button" onclick="history.go(-1)" />  
                    </td>
                </tr>
        </table>
    </div>
    </form>
</body>
</html>
